<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE>
<html>
   <head>
   	   <meta charset="utf8">
   	   <meta name="viewport" content="width=device-width, initial-scale=1">
       <link rel="stylesheet" type="text/css" href="/aquaticproduct/Public/css/bootstrap.min.css">
       <link rel="stylesheet" type="text/css" href="/aquaticproduct/Public/css/sticky-footer-navbar.css">

       <script type="application/javascript" src="/aquaticproduct/Public/js/jquery-1.11.1.min.js"></script>
       <script type="application/javascript" src="/aquaticproduct/Public/js/bootstrap.min.js"></script>
   	   
   	   <title>水产品质量溯源系统</title>

   </head>
<body>
    <!-- Fixed navbar -->
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
	        <div class="navbar-header">
	          
	          <a class="navbar-brand" href="<?php echo U('Baseadmin/Index/index');?>">水产品质量溯源系统</a>
	        </div>
	        <div id="navbar" class="collapse navbar-collapse">
	          <ul class="nav navbar-nav">
	            <li class="dropdown">
	            	<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">个人中心<span class="caret"></span></a>
	            	   <ul class="dropdown-menu">
		                <li><a href="<?php echo U('Home/User/showMe',array('role'=> '2'));?>">个人信息</a></li>
		                <li><a href="<?php echo U('Home/Index/logout');?>">退出</a></li>	                
		              </ul>
	            </li> 
	            <li class="dropdown">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">用户中心 <span class="caret"></span></a>
	              <ul class="dropdown-menu">
	                <li><a href="<?php echo U('Baseadmin/User/index');?>">注册用户</a></li>

	                <li><a href="<?php echo U('Baseadmin/User/manage');?>">用户管理</a></li>
	              </ul>
	            </li>
	           
	            <li class="dropdown">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">功能列表 <span class="caret"></span></a>
	              <ul class="dropdown-menu">
	                <li><a href="<?php echo U('Baseadmin/Safe/index');?>">池塘管理</a></li>

	              </ul>
	            </li>
	            <a class="navbar-brand" href="#">|  &nbsp&nbsp基础管理员</a>
	          </ul>
	        </div><!--/.nav-collapse -->
      </div>
    </nav>
    

   
<div class="container">
	
	<div class="row">
		<!-- <a href=""><button class="btn btn-success">  修改基地信息</button></a> -->
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addPoolModal">       添加池塘
		</button>
		<table class="table table-bordered table-striped col-sm-12" >
	     <caption>池塘基本信息:</caption>
		     <thead>
		        <tr>
		           <th>池塘名称</th>
		           <th>所属基地</th>
		           <th>池塘位置</th>
		           <th>经纬度列表</th>
		           <th>水面面积</th>
		           <th>池塘水深</th>
		           <th>养殖设施设备</th>
                   <th>养殖模式</th>
		           <th>创建时间</th>
		           <th>操作</th>
		        </tr>
		     </thead>
		     <tbody>
		     	<?php if(is_array($pool_data)): $i = 0; $__LIST__ = $pool_data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
			           <td><?php echo ($vo["pool_name"]); ?></td>
			           <td><?php echo ($vo["pool_base_id"]); ?></td>
			           <td><?php echo ($vo["pool_addr"]); ?></td>
			           <td><?php echo ($vo["pool_coordinate"]); ?></td>
			           <td><?php echo ($vo["pool_area"]); ?></td>
			           <td><?php echo ($vo["pool_depth"]); ?></td>
			           <td><?php echo ($vo["pool_equipment"]); ?></td>
			           <td><?php echo ($vo["pool_model"]); ?></td>
                       <td><?php echo ($vo["pool_time"]); ?></td>
			           <td><button class="btn btn-danger" data-toggle="modal" data-target="#modifyPoolModal" id="modifyButton" value="<?php echo ($vo["pool_id"]); ?>" onclick="change(this)">修改</button></td>
			        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
		     </tbody>
 		 </table>
	</div>
	
</div>
<!-- modifyPool模态框（Modal） -->
<div class="modal fade" id="modifyPoolModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
		   <div class="modal-dialog">
		      <div class="modal-content">
		         <div class="modal-header">
		            <button type="button" class="close" 
		               data-dismiss="modal" aria-hidden="true">
		                  &times;
		            </button>
		            <h4 class="modal-title" id="myModalLabel">
		               信息修改
		            </h4>
		         </div>
		         <div class="modal-body">
		            <form action="<?php echo U('Baseadmin/Safe/modifyPool');?>" id="modify_form"role="form" method="post">
		                <div class="form-group">
		            		<label for="">池塘名称</label>
		            		<input type="text" class="form-control" value="" name="pool_name" id="pool_name">
		            	</div>
		            	<div class="form-group">
		            		<label for="">池塘位置</label>
		            		<input type="text" class="form-control" value="" name="pool_addr" id="pool_addr">
		            	</div>
		            	<div class="form-group">
		            		<label for="">经纬度列表</label>
		            		<input type="text" class="form-control" value="" name="pool_coordinate" id="pool_coordinate">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水面面积</label>
		            		<input type="text" class="form-control" value="" name="pool_area" id="pool_area" placeholder="水面面积，例如200平方米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水深</label>
		            		<input type="text" class="form-control" value="" name="pool_depth" id="pool_depth" placeholder="水深，例如100米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖设施设备</label>
		            		<input type="text" class="form-control" value="" name="pool_equipment" id="pool_equipment" placeholder="养殖设施设备">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖模式</label>
		            		<select class="form-control"name="pool_model" id="pool_model">
		            			<option value="0">请选择养殖模式</option>
		            			<option value="大塘混养">大塘混养</option>
		            			<option value="网箱">网箱</option>
		            		</select>
		            	</div>
		            	<label class="control-label" for="input01" name="time">当前时间: <?php echo ($time); ?> </label>
		            	<div class="form-group" hidden>
		            		<input type="text" class="form-control" value="" name="pool_id" id="pool_id" >
		            	</div>

		            </form>
		         </div>
		         <div class="modal-footer">
		            <button type="button" class="btn btn-default" 
		               data-dismiss="modal">关闭
		            </button>
		            <button type="button"  id="modifyBtn" class="btn btn-primary">
		               提交更改
		            </button>
		         </div>
		      </div><!-- /.modal-content -->
		</div><!-- /.modal -->
</div>

<!-- addpool模态框（Modal） -->
<div class="modal fade" id="addPoolModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
		   <div class="modal-dialog">
		      <div class="modal-content">
		         <div class="modal-header">
		            <button type="button" class="close" 
		               data-dismiss="modal" aria-hidden="true">
		                  &times;
		            </button>
		            <h4 class="modal-title" id="myModalLabel">
		               新池塘信息
		               
		            </h4>
		         </div>
		         <div class="modal-body">
		            <form action="<?php echo U('Baseadmin/Safe/addPool');?>" id="addPool_form" role="form" method="post">
		            	<div class="form-group">
		            		<label for="">池塘名称</label>
		            		<input type="text" class="form-control" value="" name="pool_name" id="pool_name">
		            	</div>
		            	<div class="form-group">
		            		<label for="">池塘位置</label>
		            		<input type="text" class="form-control" value="" name="pool_addr" id="pool_addr">
		            	</div>
		            	<div class="form-group">
		            		<label for="">经纬度列表</label>
		            		<input type="text" class="form-control" value="" name="pool_coordinate" id="pool_coordinate">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水面面积</label>
		            		<input type="text" class="form-control" value="" name="pool_area" id="pool_area" placeholder="水面面积，例如200平方米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水深</label>
		            		<input type="text" class="form-control" value="" name="pool_depth" id="pool_depth" placeholder="水深，例如100米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖设施设备</label>
		            		<input type="text" class="form-control" value="" name="pool_equipment" id="pool_equipment" placeholder="养殖设施设备">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖模式</label>
		            		<select class="form-control"name="pool_model" id="pool_model">
		            			<option value="0">请选择养殖模式</option>
		            			<option value="大塘混养">大塘混养</option>
		            			<option value="网箱">网箱</option>
		            		</select>
		            	</div>
		            	<label class="control-label" for="input01" name="time">当前时间: <?php echo ($time); ?> </label>

		            </form>
		         </div>
		         <div class="modal-footer">
		            <button type="button" class="btn btn-default" 
		               data-dismiss="modal">关闭
		            </button>
		            <button type="button"  id="addPoolBtn" class="btn btn-primary">
		               提交
		            </button>
		         </div>
		      </div><!-- /.modal-content -->
		</div><!-- /.modal -->

</div>

    <footer class="footer">
      <div class="container">
        <p class="text-muted"><center>Copyright by 华南农业大学</center></p>
      </div>
    </footer>
  </body>
</html>
<script>
    function change(obj) { 
       
		var val = $(obj).attr('value');
        var url = "<?php echo U('Baseadmin/Safe/getChoosePool/val/"+val+"');?>";
        $.get(url, function(data, status){
        	$('#pool_id').val(data['pool_id']);
            $('#pool_name').val(data['pool_name']);
            $('#pool_base_id').val(data['pool_base_id']);
            $('#pool_addr').val(data['pool_addr']);
            $('#pool_coordinate').val(data['pool_coordinate']);
            $('#pool_area').val(data['pool_area']);
            $('#pool_depth').val(data['pool_depth']);
            $('#pool_equipment').val(data['pool_equipment']);
            $('#pool_model').val(data['pool_model']);
        });

    } 
	$(document).ready(function(){
        $('#addPoolBtn').click(function(){

        	 var action= $('#addPool_form').attr('action');
        	 var Formattr=$('#addPool_form').serialize();
             $.post(action, Formattr,function(data,status) {
                 
                 if(status == "success") {
                    alert( "添加成功！");
                 }else{
                 	alert("添加失败！");
                 }
                 setTimeout("window.location.href=\"<?php echo U('Baseadmin/Safe/index');?>\"",500);
             });
        });
      
      
        $('#modifyBtn').click(function(){

        	 var action= $('#modify_form').attr('action');
        	 var Formattr=$('#modify_form').serialize();
	         console.log(Formattr);
             $.post(action, Formattr,function(data,status) {
                 
                 if(status == "success") {
                    alert( "修改成功！");
                 }else{
                 	alert("修改失败！");
                 }
                 setTimeout("window.location.href=\"<?php echo U('Baseadmin/Safe/index');?>\"",200);
             });
        });
	});

</script>